package com.leo.blog.util;

import com.leo.blog.config.ApplicationHome;

import java.io.File;

public class PathUtil {
	private static String seperator = "/";
	
	public static String getImgBasePath() {
		String os = System.getProperty("os.name");
		String basePath =  ApplicationHome.getApplicationHome()+"/dist/static/";
//		if(os.toLowerCase().startsWith("win")) {
//			basePath = "F:/blogprojectdev/image";
//		}else {
//			basePath = "/Users/baidu/work/image";
//		}
//		basePath = basePath.replace("/", seperator);
		return new File(basePath).getPath();
	}
	
	public static String getBlogImagePath(int id) {
		String imagePath = "/upload/images/item/blog/" + id + "/";
		return imagePath.replace("/", seperator);
	}

	public static String getRealBlogImagePath(int id) {
		return getImgBasePath()+getBlogImagePath(id);
	}

	public static String getVisitBlogImagePath(String filepath) {
		return "/static/"+filepath.replace(getImgBasePath(),"").replaceAll("\\\\","/");
	}

	public static String getRealBlogImagePath(String visitpath) {
		return getImgBasePath()+visitpath.replace("/static","");
	}
}
